// import { request} from "umi";
import * as dd from 'dingtalk-jsapi'
import {request} from "../request"
// import { stringify, request, apiUrlfun } from '../config';


const parseCorpId = (url, param) => {
    var searchIndex = url.indexOf('?');
    var searchParams = url.slice(searchIndex + 1).split('&');
    for (var i = 0; i < searchParams.length; i++) {
        var items = searchParams[i].split('=');
        if (items[0].trim() == param) {
            return items[1].trim();
        }
    }
}
// 获取商品列表
export async function login( params) {
    console.log("login")
    // let  location = useLocation();
    console.log(window.location.href)
    return dd.runtime.permission.requestAuthCode({
        corpId: "dingd2861077713939e424f2f5cc6abecb85"
    }).then(res => {
        console.log(res)
        // return request("https://138j795s06.vicp.fun/cs/api/auth", {})
        return request.post("https://138j795s06.vicp.fun/dy/api", {
            name: "login",
            version:"1.0",
            data: {
                authcode: res.code
            }
        })
    })
}
